package com.hsgene.dict.exception;

import com.hsgene.common.util.exception.ErrorCode;

/**
 * @author maodi
 * @description
 * @createDate 2018/11/2 16:44
 */
public enum DictErrorCode implements ErrorCode {

    NUMBER_CANNOT_BE_EMPTY(35000, "NUMBER_CANNOT_BE_EMPTY", "编号不能为空"),
    DICT_PARENT_ID_IS_NULL(35001, "DICT_PARENT_ID_IS_NULL", "父节点id为空"),
    ORG_NOT_EXISTED(35002, "ORG_NOT_EXISTED", "职位、部门或公司信息不存在"),
    SYS_DICT_ID_IS_NOT_NULL(35003, "SYS_DICT_ID_IS_NOT_NULL", "字典id不能为空"),
    PARAMETER_CANNOT_BE_EMPTY(35004, "PARAMETER_CANNOT_BE_EMPTY", "参数不能为空"),
    SYS_DICTS_BY_SYS_DICT_ADDTION_ID_IS_ERROR(35005, "SYS_DICTS_BY_SYS_DICT_ADDTION_ID_IS_ERROR",
            "根据字典附加信息表id获取字典信息出错"),
    SELECT_ALL_CLASSIFIES_IS_ERROR(35006, "SELECT_ALL_CLASSIFIES_IS_ERROR", "获取所有分类出错"),
    SELECT_BY_PARENT_ID_IS_ERROR(35007, "SELECT_BY_PARENT_ID_IS_ERROR", "根据父节点id获取字典信息出错"),
    SELECT_BY_ID_IS_ERROR(35008, "SELECT_BY_ID_IS_ERROR", "根据id获取字典信息出错"),
    DICT_ID_IS_NOT_NULL(35009, "DICT_ID_IS_NOT_NULL", "字典id不能为空"),
    DICT_TYPE_IS_NOT_NULL(35010, "DICT_TYPE_IS_NOT_NULL", "字典分类不能为空"),
    DICT_LABEL_IS_NOT_NULL(35011, "DICT_LABEL_IS_NOT_NULL", "字典名称不能为空"),
    DICT_VALUE_IS_NOT_NULL(35012, "DICT_VALUE_IS_NOT_NULL", "字典值不能为空"),
    DICT_PARENT_ID_IS_NOT_NULL(35013, "DICT_PARENT_ID_IS_NOT_NULL", "父节点不能为空"),
    DICT_INFO_IS_NOT_NULL(35014, "DICT_INFO_IS_NOT_NULL", "字典信息不能为空"),
    QUERY_DICT_IS_ERROR(35015, "QUERY_DICT_IS_ERROR", "查询字典出错"),
    INSERT_DICT_IS_ERROR(35016, "INSERT_DICT_IS_ERROR", "新增字典出错"),
    UPDATE_DICT_IS_ERROR(35017, "UPDATE_DICT_IS_ERROR", "修改字典出错"),
    DELETE_DICT_IS_ERROR(35018, "DELETE_DICT_IS_ERROR", "删除字典出错"),
    DICT_IS_EXIST(35019, "DICT_IS_EXIST", "字典重复"),
    SYS_DICT_ADDTION_ID_IS_NOT_NULL(35020, "SYS_DICT_ADDTION_ID_IS_NOT_NULL", "字典附加信息表id不能为空"),
    DICT_HAS_BEEN_DELETED(35021, "DICT_HAS_BEEN_DELETED", "该字典已经被删除"),
    MULTI_DELETE_DICT_IS_ERROR(35022, "MULTI_DELETE_DICT_IS_ERROR", "批量删除字典出错"),
    DICT_IDS_IS_NOT_NULL(35023, "DICT_IDS_IS_NOT_NULL", "字典id数组不能为空"),
    DICT_USED_COUNT_ADD_IS_ERROR(35024, "DICT_USED_COUNT_ADD_IS_ERROR", "字典使用数量增加一次出错"),
    DICT_USED_COUNT_REDUCE_IS_ERROR(35025, "DICT_USED_COUNT_REDUCE_IS_ERROR", "字典使用数量减少一次出错"),
    DICT_IS_NOT_EXIST(35026, "DICT_IS_NOT_EXIST", "该字典不存在数据库中"),
    QUERY_LABELS_BY_CLASSIFY_ID_IS_ERROR(35027, "QUERY_LABELS_BY_CLASSIFY_ID_IS_ERROR", "根据分类id获取字典名称出错"),
    SYS_DICT_IDS_IS_NOT_NULL(35028, "SYS_DICT_IDS_IS_NOT_NULL", "字典id数组不能为空"),
    ADD_MULTI_USED_COUNT_IS_ERROR(35029, "ADD_MULTI_USED_COUNT_IS_ERROR", "批量增加字典使用数量一次出错"),
    REDUCE_MULTI_USED_COUNT_IS_ERROR(35030, "REDUCE_MULTI_USED_COUNT_IS_ERROR", "批量减少字典使用数量一次出错"),;

    private final int code;

    private final String message;

    private final String description;

    DictErrorCode(int code, String message, String description) {
        this.code = code;
        this.message = message;
        this.description = description;
    }

    public static DictErrorCode getEnum(int code) {
        for (DictErrorCode sampleErrorCode : values()) {
            if (sampleErrorCode.code == code) {
                return sampleErrorCode;
            }
        }
        throw new IllegalArgumentException("No element matches " + code);
    }

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public String getDescription() {
        return description;
    }
}
